package com.zhuiyun.pm.client.bid.response;


import lombok.Data;
import lombok.ToString;

/**
 * 通用返回结结果过实体
 *
 * @auther lyp
 * @data 2019/10/11 10:29
 */
@Data
@ToString
public class CommonResult {
    //状态码
    private int code = CommonConstants.SUCCESS;
    //提示信息
    private boolean flag = true;
    //返回结果
    private Object data;


    public static CommonResult ok(Object data) {
        CommonResult c = new CommonResult();
        c.setData(data);
        return c;
    }

    public static CommonResult ok() {
        return ok(null);
    }

    public static CommonResult error() {
        return error(CommonConstants.ERROR, null);
    }

    public static CommonResult error(Object data) {
        return error(CommonConstants.ERROR, data);
    }

    public static CommonResult error(int code, Object data) {
        CommonResult c = new CommonResult();
        c.setCode(code);
        c.setFlag(false);
        c.setData(data);
        return c;
    }
}
